package xust;
import java.util.*;

public class PetAdoption {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = scanner.nextInt();
        }

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        // 为每种颜色（1-3）创建优先队列，按领养编号x升序排列
        PriorityQueue<Pet>[] colorQueues = new PriorityQueue[4]; // 颜色1-3
        for (int i = 1; i <= 3; i++) {
            colorQueues[i] = new PriorityQueue<>(Comparator.comparingInt(p -> p.x));
        }

        // 记录宠物是否已经被领养
        boolean[] adopted = new boolean[n];

        // 初始化颜色队列：将宠物按其两种颜色加入对应队列
        for (int i = 0; i < n; i++) {
            int color1 = a[i];
            int color2 = b[i];
            Pet pet = new Pet(x[i], i);
            colorQueues[color1].add(pet);
            if (color2 != color1) {
                colorQueues[color2].add(pet);
            }
        }

        int m = scanner.nextInt();
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            c[i] = scanner.nextInt();
        }

        int[] result = new int[m];

        for (int i = 0; i < m; i++) {
            int preferredColor = c[i];
            Pet adoptedPet = null;

            // 从对应颜色的队列中取出未被领养的最小x的宠物
            while (!colorQueues[preferredColor].isEmpty()) {
                Pet candidate = colorQueues[preferredColor].peek();
                if (!adopted[candidate.index]) {
                    adoptedPet = colorQueues[preferredColor].poll();
                    break;
                } else {
                    // 已领养的宠物从队列中移除
                    colorQueues[preferredColor].poll();
                }
            }

            if (adoptedPet != null) {
                adopted[adoptedPet.index] = true;
                result[i] = adoptedPet.x;
            } else {
                result[i] = -1;
            }
        }

        // 输出结果
        for (int i = 0; i < m; i++) {
            if (i > 0) {
                System.out.print(" ");
            }
            System.out.print(result[i]);
        }
        System.out.println();
    }

    static class Pet {
        int x; // 领养编号
        int index; // 宠物在原始数组中的索引

        public Pet(int x, int index) {
            this.x = x;
            this.index = index;
        }
    }
}